<?php
class picture_special_locale_concept extends system_concept_abstract {
	
	public function init() {
		$this->setModel('picture_special_locale_model', 'locale');
		$this->setModelCols('locale', array('special_id', 'lang', 'title', 'description', 'content'));
	}

	public function save($row) {
		$row->set('special_id', intval($row->get('special_id')));
		if(!$row->getSpecialId()) {
			throw new picture_exception("Special ID can not be empty.");
		}
		if(!system_setting_language::verify($row->getLang())) {
			throw new picture_exception("Language formation error.");
		}
		if(!$row->getTitle()) {
			throw new picture_exception("Title can not be empty.");
		}
		if(!$this->fetch(array('special_id = ?' => $row->getSpecialId(), 'lang = ?' => $row->getLang()))) {
			$this->getModel('locale')->insert($row->getModelData('locale'));
		} else {
			$row->update();
		}
		return $row;
	}
}